﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace 客户端
{
    public partial class 个人信息 : Form
    {
        public static string account;
        string constr = login.constr;
        public 个人信息()
        {
            InitializeComponent();
            sx();
        }
        void sx()
        {
            SqlConnection sqlcon = new SqlConnection(constr);
            sqlcon.Open();
            string sql = "select* from Customer where Caccount='" + account + "'";
            SqlCommand sqlcmd = new SqlCommand(sql, sqlcon);
            SqlDataReader Sdr = sqlcmd.ExecuteReader();
            while (Sdr.Read())
            {
                cname.Text = Sdr["Cname"].ToString();//姓名
                cnumber.Text = Sdr["Cnumber"].ToString();
                caddress.Text = Sdr["Caddress"].ToString();
            }
        }

        private void button1_Click(object sender, EventArgs e)
        {
            SqlConnection sqlcon = new SqlConnection(constr);
            sqlcon.Open();
            string sql = "update Customer set Cname='"+cname.Text+"',Cnumber='"+cnumber.Text+"',Caddress='"+caddress.Text+"' where Caccount='"+account+"'";
            SqlCommand sqlcmd = new SqlCommand(sql, sqlcon);
            sqlcmd.ExecuteNonQuery();
            sx();
        }
    }
}
